package test;

import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by Caesar on 2016/4/3.
 */
public class dffg extends Applet implements ActionListener {

    Button bb, bn;
    TextField tt;
    int aa;

    public void init() {
        bb = new Button("画图");
        bn = new Button("清除");
        tt = new TextField(5);
        add(bb);
        add(tt);
        add(bn);
        bb.addActionListener(this);
        bn.addActionListener(this);

    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == bb) {

            int aa = Integer.parseInt(tt.getText());
            Graphics g = getGraphics();
            for (int i = 1; i < 500; i++) {
                int x = i;
                int y = (int) (Math.sin(aa * x * 3.14 / 181) * 100 + 150);
                g.drawString("s", x, y);
            }
        }
        if (e.getSource() == bn) {
            repaint();
        }

    }
}
